const {Menu,BrowserWindow }=require("electron");
let template=[
    {
        label: '文件(F)',
        submenu:[
            {
                label: '新建(N)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','new');  
                }
            },{
                label: '打开(O)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','open');  
                }
            },{
                label: '保存(S)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','save');  
                }
            },{
                label: '另存为(A)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','saveOther');  
                }
            },{ type: 'separator' },{
                label: '打印(P)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','print');  
                }
            },{ type: 'separator' },{
                label: '退出(X)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','quit');  
                }
            }
        ]
    }, {
        label: '编辑(E)',
        submenu:[
           {
                label: '剪切(O)',
                role: 'cut',
            },{
                label: '复制(S)',
                role: 'copy',
            },{
                label: '粘贴(A)',
                role: 'paste',
            },{
                label: '删除(L)',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','delete');
                }           
            },{ type: 'separator' },{
                label: '全选(A)',
                role: 'selectAll'
            }
        ]
    }, {
        label: '操作(O)',
        submenu:[
            {
                label: '撤回',
                role: 'undo'
            },{
                label: '前进',
                role: 'redo'
            }
        ]
    },{
        label: '重载',
        role:"reload"
    },{
        label: '友链',
        submenu:[
            {
                label: '开发文档',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','toDocumentPage')
                }
            },{
                label: '学习教程',
                click:()=>{
                    BrowserWindow.getFocusedWindow().webContents.send('action','toLearnPage')
                }
            }
        ]
    }
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)